package com.model;

// default package

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "db_paper", catalog = "acmctgu")
public class Paper implements java.io.Serializable {

    private static final long serialVersionUID = -7699516327966424838L;

    @Transient
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    private Integer id;
    private User user;
    private String papername;
    private String isjava;
    private Timestamp begintime;
    private Timestamp endtime;
    private String paperpw;
    private Integer totalprogram;
    private Set<Clazz> Classes = new HashSet<Clazz>(0);
    private Set<Programming> paperPrograms = new HashSet<Programming>(0);
    private Set<Apply> applies = new HashSet<Apply>(0);
    private String isvisible;
    private String rank; // 是否排名

    private String status; // 不与数据库映射

    // Constructors

    /** default constructor */
    public Paper() {
    }

    // Property accessors

    @Id
    // @GeneratedValue
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "teacherid", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(name = "papername", nullable = false, length = 50)
    public String getPapername() {
        return this.papername;
    }

    public void setPapername(String papername) {
        this.papername = papername;
    }

    @Column(name = "isjava", nullable = false, length = 4)
    public String getIsjava() {
        return this.isjava;
    }

    public void setIsjava(String isjava) {
        this.isjava = isjava;
    }

    // @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "begintime", length = 10)
    public Timestamp getBegintime() {
        return this.begintime;
    }

    public void setBegintime(Timestamp begintime) {
        this.begintime = begintime;
    }

    // @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "endtime", length = 10)
    public Timestamp getEndtime() {
        return this.endtime;
    }

    public void setEndtime(Timestamp endtime) {
        this.endtime = endtime;
    }

    @Column(name = "paperpw", length = 30)
    public String getPaperpw() {
        return this.paperpw;
    }

    public void setPaperpw(String paperpw) {
        this.paperpw = paperpw;
    }

    @Column(name = "totalprogram", length = 10)
    public Integer getTotalprogram() {
        return this.totalprogram;
    }

    public void setTotalprogram(Integer totalprogram) {
        this.totalprogram = totalprogram;
    }

    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
    @JoinTable(name = "db_paperprogram", joinColumns = { @JoinColumn(name = "paperid") }, inverseJoinColumns = { @JoinColumn(name = "programid", nullable = true) })
    public Set<Programming> getPaperPrograms() {
        return this.paperPrograms;
    }

    public void setPaperPrograms(Set<Programming> paperPrograms) {
        this.paperPrograms = paperPrograms;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "paper")
    public Set<Apply> getApplies() {
        return this.applies;
    }

    public void setApplies(Set<Apply> applies) {
        this.applies = applies;
    }

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "db_paperclass", joinColumns = @JoinColumn(name = "paperid"), inverseJoinColumns = @JoinColumn(name = "classid"))
    public Set<Clazz> getClasses() {
        return Classes;
    }

    public void setClasses(Set<Clazz> Classes) {
        this.Classes = Classes;
    }

    public String getIsvisible() {
        return isvisible;
    }

    public void setIsvisible(String isvisible) {
        this.isvisible = isvisible;
    }

    @Column(name = "rank", nullable = true, length = 4)
    public String getRank() {
        return rank;
    }

    public void setRank(String rank) {
        this.rank = rank;
    }

}